local blaze = require "blaze"
local game = require "club.threecard.sudoku"

local AvatarIcon = require "ui.Common.AvatarIcon"
local HeartBar = require "club.threecard.sudoku.ui.common.HeartBar"
local PuzzleBar = require "club.threecard.sudoku.ui.common.PuzzleBar"
local PuzzleProgressBar = require "club.threecard.sudoku.ui.common.PuzzleProgressBar"

local M = game.ui.element()

function M:ctor()
    self.icon = AvatarIcon.new()
    self.hearts = HeartBar.new()
    self.puzzles = PuzzleBar.new()
    self.progress_bar = PuzzleProgressBar.new()
end

function M:on_load()
    self:super("on_load")
    self.hearts:load()
    self.puzzles:load()
end

function M:on_injected(bind)
    bind("gameobject.element", self.icon_obj, self.icon)
    bind("gameobject.element", self.progress_bar_obj, self.progress_bar)
    self.hearts:set_parent(self.hearts_root)
    self.puzzles:set_parent(self.puzzles_root)
end

function M:set_player(player)
    self.icon:set_head(player.head)
    self.name_txt.text = player.name
end

function M:set_progress(value)
    self.progress_bar:set_progress(value, true)
end

function M:set_hearts(current, max)
    self.hearts:set_value(current, max)
end

function M:set_puzzles(solved, max)
    self.puzzles:set_value(solved, max)
end

function M:show_enter()
    print("[TODO]玩家进来效果表现")
end

function M:show_leave()
    print("[TODO]玩家离开效果表现")
end

return M